package shiyan1;

/**
 * Created by zhangyunqi on 2017/6/7.
 */

import java.util.Scanner;

public class MyDCTester {

    public static void main(String[] args) {

        String expression, again;

        int result;

        try {
            Scanner in = new Scanner ( System.in );

            do {
                MyDC evaluator = new MyDC ();
                System.out.println ( "Enter a valid postfix expression: " );
                expression = in.nextLine ();

                String postfix = MyBC.toPostfix ( expression );
                System.out.println ( "The postfix expression is :" + postfix );
                result = evaluator.evaluate ( postfix );
                System.out.println ( "That expression equals :" + result );
                System.out.print ( "Evaluate another expression [Y/N]? " );
                again = in.nextLine ();
                System.out.println ();
            }
            while (again.equalsIgnoreCase ( "y" ));
        } catch (Exception IOException) {
            System.out.println ( "Input exception reported" );
        }
    }
}
